/*
 * @Description:按需引入
 * @Autor: henry.xiukun
 * @Date: 2021-06-05 17:12:35
 * @LastEditors: henry.xiukun
 */
import {
    locale,
    ElAlert,
    ElAside,
    ElAutocomplete,
    ElAvatar,
    ElBacktop,
    ElBadge,
    ElBreadcrumb,
    ElBreadcrumbItem,
    ElButton,
    ElButtonGroup,
    ElCalendar,
    ElCard,
    ElCarousel,
    ElCarouselItem,
    ElCascader,
    ElCascaderPanel,
    ElCheckbox,
    ElCheckboxButton,
    ElCheckboxGroup,
    ElCol,
    ElCollapse,
    ElCollapseItem,
    ElCollapseTransition,
    ElColorPicker,
    ElContainer,
    ElDatePicker,
    ElDialog,
    ElDivider,
    ElDrawer,
    ElDropdown,
    ElDropdownItem,
    ElDropdownMenu,
    ElFooter,
    ElForm,
    ElFormItem,
    ElHeader,
    ElIcon,
    ElImage,
    ElInput,
    ElInputNumber,
    ElLink,
    ElMain,
    ElMenu,
    ElMenuItem,
    ElMenuItemGroup,
    ElOption,
    ElOptionGroup,
    ElPageHeader,
    ElPagination,
    ElPopconfirm,
    ElPopover,
    ElPopper,
    ElProgress,
    ElRadio,
    ElRadioButton,
    ElRadioGroup,
    ElRate,
    ElRow,
    ElScrollbar,
    ElSelect,
    ElSlider,
    ElStep,
    ElSteps,
    ElSubmenu,
    ElSwitch,
    ElTabPane,
    ElTable,
    ElTableColumn,
    ElTabs,
    ElTag,
    ElTimePicker,
    ElTimeSelect,
    ElTimeline,
    ElTimelineItem,
    ElTooltip,
    ElTransfer,
    ElTree,
    ElUpload,
    ElInfiniteScroll,
    ElLoading,
    ElMessage,
    ElMessageBox,
    ElNotification,
} from 'element-plus'; // Element Plus 组件内部默认使用英语
// 插件按需引入 Element Plus 设置中文要独立引入locale
import lang from 'element-plus/lib/locale/lang/zh-cn';
import 'dayjs/locale/zh-cn';
// import locale from 'element-plus/lib/locale';

export default function (app) {
    locale(lang); //默认英文，初始化设置为中文
    // 组件列表
    const components = [
        ElAlert,
        ElAside,
        ElAutocomplete,
        ElAvatar,
        ElBacktop,
        ElBadge,
        ElBreadcrumb,
        ElBreadcrumbItem,
        ElButton,
        ElButtonGroup,
        ElCalendar,
        ElCard,
        ElCarousel,
        ElCarouselItem,
        ElCascader,
        ElCascaderPanel,
        ElCheckbox,
        ElCheckboxButton,
        ElCheckboxGroup,
        ElCol,
        ElCollapse,
        ElCollapseItem,
        ElCollapseTransition,
        ElColorPicker,
        ElContainer,
        ElDatePicker,
        ElDialog,
        ElDivider,
        ElDrawer,
        ElDropdown,
        ElDropdownItem,
        ElDropdownMenu,
        ElFooter,
        ElForm,
        ElFormItem,
        ElHeader,
        ElIcon,
        ElImage,
        ElInput,
        ElInputNumber,
        ElLink,
        ElMain,
        ElMenu,
        ElMenuItem,
        ElMenuItemGroup,
        ElOption,
        ElOptionGroup,
        ElPageHeader,
        ElPagination,
        ElPopconfirm,
        ElPopover,
        ElPopper,
        ElProgress,
        ElRadio,
        ElRadioButton,
        ElRadioGroup,
        ElRate,
        ElRow,
        ElScrollbar,
        ElSelect,
        ElSlider,
        ElStep,
        ElSteps,
        ElSubmenu,
        ElSwitch,
        ElTabPane,
        ElTable,
        ElTableColumn,
        ElTabs,
        ElTag,
        ElTimePicker,
        ElTimeSelect,
        ElTimeline,
        ElTimelineItem,
        ElTooltip,
        ElTransfer,
        ElTree,
        ElUpload,
    ];

    components.forEach((component) => {
        app.component(component.name, component);
    });

    const plugins = [ElInfiniteScroll, ElLoading, ElMessage, ElMessageBox, ElNotification];

    plugins.forEach((plugin) => {
        app.use(plugin);
    });

    // 全局配置
    // 该对象目前支持 size 与 zIndex 字段。size 用于改变组件的默认尺寸 small，zIndex 设置弹框的初始 z-index（默认值：2000）
    app.config.globalProperties.$ELEMENT = {
        size: 'medium',
    };
    // 完整引入
    // app.use(ElementPlus, { size: 'small', zIndex: 2000, locale });
}
